﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MobileControlGuru.Src
{
    public class JobStatusTracker
    {
        private readonly ConcurrentDictionary<string, JobStatus> _statusMap = new ConcurrentDictionary<string, JobStatus>();

        public void SetStatus(string jobKey, JobStatus status)
        {
            Console.WriteLine($"SetStatus  {jobKey} {status}");
            _statusMap[jobKey] = status;
        }

        public JobStatus GetStatus(string jobKey)
        {
            
            return _statusMap.TryGetValue(jobKey, out JobStatus status) ? status : JobStatus.NotScheduled;
        }
        public int CountRunningJobs()
        {
            return _statusMap.Count(kvp => kvp.Value == JobStatus.Running);
        }
        public int CountScheduledJobs()
        {
            return _statusMap.Count(kvp => kvp.Value == JobStatus.Scheduled);
        }
        // 其他辅助方法，如获取所有任务状态、清除状态等
    }
}
